﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using ZHDJ.Data.Models.Common;

namespace ZHDJ.Data.Models.Edu
{
    public class PartyeduLessonimage : EntityBaseOperation
    {
        #region 属性

        /// <summary>
        /// 课程ID
        /// </summary>
        [StringLength(128)]
        public string LessonID { get; set; }

        /// <summary>
        /// FileID
        /// </summary>
        [StringLength(128)]
        public string FileID { get; set; }

        /// <summary>
        /// 附件类型（2：普通图片，4 封面图片）
        /// </summary>
        public int FileType { get; set; }

        /// <summary>
        /// （2禁用4启用）
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// OrderNo
        /// </summary>
        public int OrderNo { get; set; }

        public virtual PartyEduLesson PartyEduLesson { get; set; }
        public virtual PartyFile PartyFile { get; set; }

        #endregion

        public static void SetCover(string id, string coursewareId)
        {

            List<MySqlParameter> parameters = new List<MySqlParameter>()
            {
                new MySqlParameter() {DbType = DbType.String, ParameterName = "ID", Value = id},
                new MySqlParameter() {DbType = DbType.String, ParameterName = "CoursewareID", Value = coursewareId}
            };


            StringBuilder sb = new StringBuilder();
            sb.Append(@"update tblPartyEduCoursewareImage set FileType=2 where CoursewareID=?CoursewareID;
                        update tblPartyEduCoursewareImage set FileType=4 where ID=?ID;
                       ");

            MySqlHelper.ExecuteNonQuery(sb.ToString(), parameters.ToArray());

        }
    }
}
